package main

import (
	"fmt"
)

type Animal struct {
	Name string
	Age int
	Sex string
	Comment string
}

func (a *Animal) PrintName1(){
	fmt.Printf("----->name1:%v \n", a.Name)
	a.Name = "PrintName1"
}
func (a Animal) PrintName2(){
	fmt.Printf("----->name2:%v \n", a.Name)
	a.Name = "PrintName2"
}

func test1() {
	a := new(Animal)
	a.Name = "Panda"
	a.Age = 20
	a.Sex = "man"
	a.Comment = "gun"

	fmt.Println(a, &a)

	b := &Animal{}
	b.Name = "dog"
	b.Age = 30
	b.Sex = "fade"
	fmt.Println(b)

	//匿名结构体
	lala := struct{
		name string
		age int
	}{
		name:"sdsf",
		age:19,
	}
	fmt.Println("匿名结构体 ",lala)
	fmt.Println("main function end")
}

func test2() {
	a := Animal{}
	a.Name = "Panda"
	a.Age = 20
	a.Sex = "man"
	a.Comment = "gun"
	//a.PrintName1()
	a.PrintName2()
	fmt.Printf("a:%+v", a)
}

//信道 channel
func main() {
	fmt.Println("hello start")


	test2()




}
